<template>
  <div class="pdf-container">
    <vue-pdf-embed
      :source="pdfUrl"
      :page="currentPage"
      @loaded="onLoaded"
      style="width: 100%;"
    />
    <div class="pagination">
      <van-button 
        :disabled="currentPage === 1"
        @click="currentPage--">
        上一页
      </van-button>
      <span>{{ currentPage }} / {{ totalPages }}</span>
      <van-button 
        :disabled="currentPage === totalPages"
        @click="currentPage++">
        下一页
      </van-button>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useRoute } from 'vue-router'
import VuePdfEmbed from 'vue-pdf-embed'

const route = useRoute()
const currentPage = ref(1)
const totalPages = ref(1)
const pdfUrl = ref('')

onMounted(async () => {
  const id = route.params.id
  // 这里替换成实际的 PDF URL
  pdfUrl.value = `/api/reports/${id}/pdf`
})

const onLoaded = ({ numPages }) => {
  totalPages.value = numPages
}
</script>

<style scoped>
.pdf-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.pagination {
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
}
</style> 